#源镜像
FROM golang:1.15



# Make ssh dir
RUN mkdir /root/.ssh/

# Copy over private key, and set permissions
#COPY id_rsa /root/.ssh/id_rsa
#COPY id_rsa.pub /root/.ssh/id_rsa.pub
ADD ./.ssh /root/.ssh
RUN chmod 700 /root/.ssh/id_rsa
RUN chown -R root:root /root/.ssh

# Create known_hosts
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts

# Remove host checking
#RUN echo "Host bitbucket.org\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config


#设置工作目录
WORKDIR $GOPATH/src/

#拉取项目代码
RUN git clone git@gitee.com:hhhhjj/go_im.git
#COPY . $GOPATH/src/go_im

#添加配置文件
ADD ./config/app.yaml.example $GOPATH/src/go_im/config/app.yaml

#切换工作目录
WORKDIR $GOPATH/src/go_im/

#设置代理
ENV GOPROXY https://mirrors.aliyun.com/goproxy/

#go构建可执行文件
RUN go build main.go

#暴露端口
#http端口
EXPOSE 8080
#websocket 端口
EXPOSE 8089
#rpc端口
EXPOSE 9001

#最终运行docker的命令
ENTRYPOINT  ["./main"]
